<template>
  <div id="app">
    <!-- template 下，只能由一个根元素 -->
    <HomeView v-if="isLogin" />
    <LoginView
      v-else
      :title="title"
      :age="age"
      @changeLogin="changeIsLogin"
    ></LoginView>
    <!--  @changeLogin="changeIsLogin", 绑定一个自定义事件,
      在子组件里面通过 this.$emit()来触发自定义的事件<div class=""></div> -->
  </div>
</template>

<script>
import HomeView from "./views/HomeView.vue";
import LoginView from "./views/LoginView.vue";
export default {
  data() {
    return {
      isLogin: false,
      title: "LOG IN",
      age: "23",
    };
  },
  components: {
    HomeView,
    LoginView,
  },
  methods: {
    changeIsLogin(value) {
      // value,接收 this.$emit()传递的实际参数.
      this.isLogin = value;
    },
  },
};
</script>

<style>
* {
  margin: 0;
  padding: 0;
}
body,
html {
  height: 100%;
  /* font-size: 62.5%;  */
  /* 10px, 1rem = 10px, 1.5rem=15px */
}
.height-100 {
  height: 100%;
}
#app {
  height: 100%;
}
</style>